package com.fay.basic.proxy;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;

public class PC {

    private final int MAX_LEN = 10;

    private Queue<Integer> queue = new LinkedList<>();

    class Producer extends Thread {

        @Override
        public void run() {
            producer();
        }

        private void producer() {
            while (true) {
                synchronized (queue) {
                    while (queue.size() == MAX_LEN) {
                        queue.notify();
                        System.out.println("满啦");
                        ArrayList<Integer> list = new ArrayList<>();

                        try {
                            queue.wait();
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
